'abubasics.monkey by Belimoth
Strict



Const DIRECTION_NORTH:Int = 0
Const DIRECTION_EAST:Int = 1
Const DIRECTION_SOUTH:Int = 2
Const DIRECTION_WEST:Int = 3

Const DIRECTION_NORTHEAST:Int = 4
Const DIRECTION_SOUTHEAST:Int = 5
Const DIRECTION_SOUTHWEST:Int = 6
Const DIRECTION_NORTHWEST:Int = 7

Global DIRECTIONS_CARDINAL:Int[] = [DIRECTION_NORTH, DIRECTION_EAST, DIRECTION_SOUTH, DIRECTION_WEST]
Global DIRECTIONS_4A:Int[] = DIRECTIONS_CARDINAL

Global DIRECTIONS_ORDINAL:Int[] = [DIRECTION_NORTHEAST, DIRECTION_SOUTHEAST, DIRECTION_SOUTHWEST, DIRECTION_NORTHWEST]
Global DIRECTIONS_INTERCARDINAL:Int[] = DIRECTIONS_ORDINAL
Global DIRECTIONS_INTERMEDIATE:Int[] = DIRECTIONS_ORDINAL
Global DIRECTIONS_4B:Int[] = DIRECTIONS_ORDINAL

Global DIRECTIONS_ALL:Int[] = [DIRECTION_NORTH, DIRECTION_NORTHEAST, DIRECTION_EAST, DIRECTION_SOUTHEAST, DIRECTION_SOUTH, DIRECTION_SOUTHWEST, DIRECTION_WEST, DIRECTION_NORTHWEST]
Global DIRECTIONS_8:Int[] = DIRECTIONS_ALL

Global DIRECTIONS_6A:Int[] = [DIRECTION_NORTH, DIRECTION_NORTHEAST, DIRECTION_SOUTHEAST, DIRECTION_SOUTH, DIRECTION_SOUTHWEST, DIRECTION_NORTHWEST]
Global DIRECTIONS_6B:Int[] = [DIRECTION_NORTHEAST, DIRECTION_EAST, DIRECTION_SOUTHEAST, DIRECTION_SOUTHWEST, DIRECTION_WEST, DIRECTION_NORTHWEST]



'TODO use this?
Class XY<T>
	Field x:T, y:T
	
	Method New(x:T, y:T)
		Self.x = x
		Self.y = y
	End
End



'TODO update all of these below
Function OppositeDirection:Int(direction:Int)
	Return (direction + 2) Mod 4
End



Function XyToDirection:Int(x:Int, y:Int)
	'TODO revise this
	If y < 0 Then Return DIRECTION_NORTH
	If x > 0 Then Return DIRECTION_EAST
	If y > 0 Then Return DIRECTION_SOUTH
	If x < 0 Then Return DIRECTION_WEST
	Return 0
End



Function DirectionToX:Int(direction:Int)
	If direction = DIRECTION_WEST Then Return -1
	If direction = DIRECTION_EAST Then Return 1
	Return 0
End



Function DirectionToY:Int(direction:Int)
	If direction = DIRECTION_NORTH Then Return -1
	If direction = DIRECTION_SOUTH Then Return 1
	Return 0
End